from pydantic import BaseModel, Field
from datetime import datetime, timedelta, timezone


class OutlookEvent(BaseModel):
    token: str = Field(description="Verification token")
    subject: str
    body_html: str
    start_iso: str
    end_iso: str
    timezone: str = "UTC"

    @staticmethod
    def near_future(token: str, minutes_from_now: int = 30) -> "OutlookEvent":
        now = datetime.now(timezone.utc)
        start = now + timedelta(minutes=minutes_from_now)
        end = start + timedelta(minutes=45)
        return OutlookEvent(
            token=token,
            subject=f"{token} Planning Sync",
            body_html=f"<p>Autogenerated test event. Token: <b>{token}</b></p>",
            start_iso=start.isoformat(),
            end_iso=end.isoformat(),
            timezone="UTC",
        )
